﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
using CMD.BAL.MISC;

namespace CMD_WEB.Reportes
{
    public partial class ReporteSolicitudes : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            

            if (!IsPostBack)
            {
                //string sFecha = DateTime.Now.ToShortDateString();
                DateTime fecha = Utilities.NowWithENFormat();

                this.HiddenFechaIni.Value = fecha.ToString("yyyy/MM/dd");
                this.HiddenFechaFin.Value = fecha.ToString("yyyy/MM/dd");

                //this.HiddenFechaIni.Value = DateTime.Now.ToShortDateString();
                //this.HiddenFechaFin.Value = DateTime.Now.ToShortDateString();
                this.HiddenNombreCliente.Value = "";
                
                this.txtFechaIni.SelectedValue = fecha;     //DateTime.Now; //this.HiddenFechaIni.Value;
                this.txtFechaFin.SelectedValue = fecha;     // DateTime.Now;
            }
        }

        protected void btnConsultar_Click(object sender, EventArgs e)
        {

            consultarReporte();
        }

        private void consultarReporte()
        {
            DateTime fecha = Utilities.NowWithENFormat();
            string ini = this.txtFechaIni.SelectedDate.ToString("yyyy/MM/dd");
            string fin = this.txtFechaFin.SelectedDate.ToString("yyyy/MM/dd");

            //this.HiddenFechaIni.Value = (this.txtFechaIni.SelectedDate.ToShortDateString() == "1/1/0001") ? DateTime.Now.ToShortDateString() : this.txtFechaIni.SelectedDate.ToShortDateString();
            this.HiddenFechaIni.Value = (this.txtFechaIni.SelectedDate.ToShortDateString() == "1/1/0001") ? fecha.ToString("yyyy/MM/dd") : ini;
            this.HiddenFechaFin.Value = fin;    //this.txtFechaFin.SelectedDate.ToShortDateString();
            this.HiddenNombreCliente.Value = this.txtNombreCliente.Text;
            this.r2.LocalReport.Refresh();
        }


        

    }
}